package cn.tao.order.controller;

import cn.tao.order.service.IOrderAdoptService;
import cn.tao.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/adoptorder")
public class OrderAdoptController {


    @Autowired
    private IOrderAdoptService orderAdoptService;
    /**
     * 提交订单
     * @return
     * 接收的参数：
     * addressId    1
     * payway	"ALIPAY"
     * petId	11
     */
    @PostMapping("/createOrder")
    public AjaxResult createOrder(@RequestBody Map<String,String> map, HttpServletRequest request){
        try {
            orderAdoptService.createOrder(map,request);
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setMessage(e.getMessage());
        }
    }

}
